// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.2 OR LicenseRef-Slint-commercial

component Item {
    callback pointer-event <=> touch.pointer-event;
    touch := TouchArea {}
}

component Issue3148 {
    out property <length> result;
    Item {
        x: 42px;
        pointer-event => {
            debug(self.absolute-position.x - root.absolute-position.x);
        }
        init => {
            result = self.absolute-position.x - root.absolute-position.x
        }
    }
}

export component TestCase {
    width: 500phx;
    height: 500phx;

    property <bool> simple-inner-ok: simple-inner.absolute-position.x == 40phx && simple-inner.absolute-position.y == 60phx;
    Rectangle {
        x: 10phx;
        y: 20phx;

        simple-inner := Rectangle {
            x: 30phx;
            y: 40phx;
        }
    }
    empty1 := Rectangle {
        Rectangle {
            empty2 := Rectangle {

            }
        }
    }
    xxx := Issue3148 { width: 50%; }
    out property <bool> test: simple-inner-ok && xxx.result == 42px && empty1.absolute-position == empty2.absolute-position;
    out property <Point> coords <=> simple-inner.absolute-position;
}

/*
```rust
let instance = TestCase::new().unwrap();
assert!(instance.get_test());
let pos: slint::LogicalPosition = instance.get_coords();
assert_eq!(pos.x, 40.);
assert_eq!(pos.y, 60.);
```

```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;
assert(instance.get_test());
slint::LogicalPosition pos = instance.get_coords();
assert_eq(pos.x, 40);
assert_eq(pos.y, 60);
```

```js
let instance = new slint.TestCase({});
assert(instance.test, 1);
assert.deepEqual(instance.coords, { x: 40, y: 60});
```

*/
